package group2assignone.view.customer;

import group2assignone.func.UCCtoALAdapter;
import group2assignone.model.Booking;
import group2assignone.model.Customer;
import group2assignone.ucm.customer.UCUIBookingConfirmed;
import group2assignone.view.OurView;
import java.awt.GridLayout;
import javax.swing.*;
import javax.swing.border.EtchedBorder;

/**
 *
 * @author group2
 */
public class BookingConfirmedView extends OurView {

    private JLabel custLab;
    private JButton logout = new JButton("Logout");
    private JButton ok = new JButton("OK");
    private JLabel noTicketsLab = new JLabel("");
    private JLabel fNameLab = new JLabel("");
    private JLabel lNameLab = new JLabel("");
    private JLabel dobLab = new JLabel("");
    //booking number, total cost etc 
    private GridLayout grid;
    private Customer customer;
    private Booking booking;

    public BookingConfirmedView(Customer customer, Booking booking) {
        this.customer = customer;
        this.booking = booking;
    }

    /**
     * Function to add the GUI components to the frame.
     */
    @Override
    public void addComponents() {

        setTitle("Booking Confirmed");
        custLab = new JLabel("Welcome " + customer.getUsername());

        custLab = new JLabel("Welcome " + customer.getUsername());
        northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.LINE_AXIS));
        custLab.setAlignmentX(JLabel.LEFT);
        logout.setAlignmentX(JButton.RIGHT);
        northPanel.add(custLab);
        northPanel.add(Box.createHorizontalGlue());
        northPanel.add(Box.createVerticalStrut(10));
        if (!customer.getUsername().equals("Guest")) {
            northPanel.add(logout);
        }

        grid = new GridLayout(4, 2, 2, 1);
        centerPanel.setLayout(grid);
        grid.setVgap(20);

        centerPanel.add(noTicketsLab);
        centerPanel.add(fNameLab);
        centerPanel.add(lNameLab);
        centerPanel.add(dobLab);

        southPanel.add(ok);

        centerPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
        northPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
        southPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));

        ok.addActionListener(new UCCtoALAdapter(new UCUIBookingConfirmed(customer, this)));
    }
}
